package leetcode.l0618;

import leetcode.l0526.TreeNode;

/**
 * @author Retain
 * @date 2021/6/18 17:01
 */
public class Medium_验证二叉搜索树_98 {

    private long PRE = Integer.MIN_VALUE;
    public boolean isValidBST(TreeNode root) {
        if (root == null) {
            return true;
        }
        boolean left = isValidBST(root.left);
        if (root.val <= PRE) {
            return false;
        }
        PRE = root.val;
        boolean right = isValidBST(root.right);
        return left & right;
    }

}
